import { getHomeData } from '@/api/index'

const actions = {
    // home页面初始化数据
    async getHomeInitData({commit}){
        const result = await getHomeData()
        // console.log(result)
        commit('HOMEINITDATA',result.data)
    }
}
const mutations = {
    HOMEINITDATA(state,data){
        state.initData = data
    }
}
const state = {
    initData:{}
}
const getters = {
    // 轮播图
    bannerList(state){
        return state.initData.banner || []
    },
    // 导航栏
    categoryList(state){
        return state.initData.categoryList || []
    },
    // 热卖品
    hotGoodsList(state){
        return state.initData.hotGoodsList
    },
    // 导航宫格
    channelList(state){
        return state.initData.channel
    }
}

export default {
    actions,
    mutations,
    state,
    getters
}